{include file="inc/header.html"}
<script type="text/javascript" src="{$TMPL}/js/jscharts_cr.js"></script>
<adv adv_id="我要理财列表页顶部广告" />
	<p class="pos"><a href="{url x="index" r="index"}">首页</a> > <a href="{url x="index" r="transfer"}">投资列表</a></p>
	<div id="content" class="clearfix">
		<div class="short filterbox">
			<div class="bddf clearfix" id="deallist" name="deallist">
				<div class="filter clearfix">
		            <div class="f_l f_dgray b">筛选条件</div>
		        </div>
				<div class="propAttrs clearfix pr {if $level neq 0 || $interest neq 0 || $lefttime neq 0}v{/if}" id="search_condition" {if $level eq 0 && $interest eq 0 && $lefttime eq 0}style="height:130px"{/if}>
					<a href="javascript:void(0);" class="j_more  ps" style="bottom:10px;right:10px;z-index:10;color:#01bcef">更多筛选</a>
		            <form action="{url x="index" r="deals" p="cid=$cid"}" method="post" id="searchByConditionForm">
		                
						{if $cate_list_url}
						<div class="attr">
		                    <div class="attrKey">认证标识：</div>
		                    <div class="attrValues">
								<ul class="av-collapse" id="dashboard">
									{foreach from =$cate_list_url item="cates" key=key}
									<li >
										<a href="{$cates.url}#deallist" {if $cates.id eq $cate_id}class="cur"{/if}>{$cates.name}</a>
									</li>
									{/foreach}								
								</ul>
		                    </div>
		                </div>
						{/if}
						
						 <div class="attr">
							<div class="attrKey">区域列表：</div>
							<div class="attrValues">
								<ul class="av-collapse" name="city" id="city">
									{foreach from="$city_urls" item="city" key=key}
		                            <li><a href="{$city.url}#deallist"  {if $city.id eq $city_id} class="cur" {/if}>{$city.name}</a></li>
									{/foreach}
		                        </ul>
		                    </div>
		                </div>
						{if $sub_citys}
						<div class="attr">
							<div class="attrKey">城市列表：</div>
							<div class="attrValues">
								<ul class="av-collapse" name="city" id="city">
									{foreach from="$sub_citys" item="scity" key=key}
		                            <li><a href="{$scity.url}#deallist"  {if $scity.id eq $scity_id} class="cur" {/if}>{$scity.name}</a></li>
									{/foreach}
		                        </ul>
		                    </div>
		                </div>
						{/if}
						
						
						<div class="attr">
							<div class="attrKey">借款期限：</div>
							<div class="attrValues">
								<ul class="av-collapse" name="interest" id="months">
									{foreach from="$months_type_url" item="months" key=key}
		                            <li><a href="{$months.url}#deallist" {if $key eq $months_type}class="cur"{/if}>{$months.name}</a></li>
									{/foreach}
		                        </ul>
		                    </div>
		                </div>
						<div class="attr">
		                    <div class="attrKey">借款状态：</div>
							
		                    <div class="attrValues">
								<ul class="av-collapse" id="dashboard">
									{foreach from =$deal_status_url item="status" key=key}
									<li >
										<a href="{$status.url}#deallist" {if $key eq $deal_status}class="cur"{/if}>{$status.name}</a>
									</li>
									{/foreach}
																				
								</ul>
		                    </div>
		                </div>
						
						<div class="attr">
		                    <div class="attrKey">信誉等级：</div>
		                    <div class="attrValues">
								<ul class="av-collapse" name="level" id="level">
									{foreach from =$level_list_url item="ilevel" key=key}
								   <li>
									   <a href="{$ilevel.url}#deallist" {if $level eq $ilevel.id}class="cur"{/if}>{$ilevel.name}{if $key neq 0}以上{/if}</a>
								   </li>
								   {/foreach}
								</ul>
							</div>
		                </div>
						<div class="attr">
		                    <div class="attrKey">回馈利率：</div>
		                    <div class="attrValues">
								<ul class="av-collapse" name="interest" id="interest">
		                           {foreach from =$interest_url item="iinterest" key=key}
								   <li>
									   <a href="{$iinterest.url}#deallist" {if $interest eq $iinterest.interest}class="cur"{/if}>{$iinterest.name}{if $key neq 0}以上{/if}</a>
								   </li>
								   {/foreach}
		                        </ul>
		                    </div>
		                </div>
						
						<div class="attr">
		                    <div class="attrKey">剩余时间：</div>
		                    <div class="attrValues">
								<ul class="av-collapse" name="lefttime" id="lefttime">
		                            {foreach from =$lefttime_url item="ilefttime" key=key}
								   <li>
									   <a href="{$ilefttime.url}#deallist" {if $lefttime eq $ilefttime.lefttime}class="cur"{/if}>{$ilefttime.name}{if $key neq 0}以内{/if}</a>
								   </li>
								   {/foreach}
		                        </ul>
		                    </div>
		                </div>
		                
		               
		                
		            </form>
		        </div>
			</div>
			<div class="blank"></div>
			<div class="blank"></div>
		</div>
		<div class="list">
			<div class="list_title clearfix">
				<div class="list1 cur" >投资列表</div>
				<div class="list2" onclick="window.location.href='{url x="index" r="transfer"}'">债权转让</div>
				<a href="{url x="index" r="tool"}" class="calt">理财计算器</a>
			</div>
			<div class="list_cont">
				<div class="i_deal_list clearfix">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tbody>
							<tr  border="0" style="background-color:#00bef0; color:#fff; height:34px;">
								<th style="width:30%">借款标题</th>
								<th style="width:15%">借款金额</th>
								<th style="width:10%">信用等级</th>
								<th style="width:10%">年利率</th>
								<th style="width:10%">借款进度</th>
								<th style="width:10%">借款期限</th>
								<th style="width:15%">借款状态</th>
							</tr>
							{if $deal_list}
							{foreach from=$deal_list item="deal" key=key name="deal"}
							<tr class="item {if $key mod 2 eq 1}item_1{/if}" {if $smarty.foreach.deal.last}style="border-bottom:0"{/if}>
								<td class="tl pl10">
									&nbsp;&nbsp;<img src="{$deal.cate_info.icon}" width="24" height="24"  class="ico" />
									<a href="{$deal.url}">{$deal.color_name}</a>
								</td>
								<td>
									<span>{$deal.borrow_amount_format}</span>
								</td>
								<td>
									<img src="{$TMPL}/images/{$deal.user.point_level}.png" align="absmiddle" title="{$deal.user.point_level}" alt="{$deal.user.point_level}" height="40" />
								</td>
								<td>
									<span>{$deal.rate} %</span>
								</td>
								<td>					
									<div class="graph-box">
										<p>
											{if  $deal.deal_status eq 5}
											100%
											{elseif $deal.deal_status eq 4}
											{function name='round' v='$deal.repay_progress_point' f=0}%
											{else}
											{function name="round" v=$deal.progress_point f=0}%
											{/if}
										</p>
				                    	<div id="graph-{$deal.id}"></div>
									</div>
									<script type="text/javascript">
									  	{if  $deal.deal_status eq 5}
										<!--//已还清-->
										var colors = ['#00bef0', '#e7e5e5'];
										var myData = new Array(['OK', 100], ['NO', 0]);
										{elseif $deal.deal_status eq 4}
										<!--//还款中-->
										var colors = ['#00bef0', '#e7e5e5'];
										var myData = new Array([' ', {function name='round' val=$deal.repay_progress_point f=2}], [' ', <?php echo 100-round($this->_var['deal']['repay_progress_point'],2) ?>]);
										{else}
										<!--//筹款中-->
										var colors = ['#00bef0', '#e7e5e5'];
										var myData = new Array([' ', {function name='round' val=$deal.progress_point f=2}], [' ', <?php echo 100-round($this->_var['deal']['progress_point'],2) ?>]);
										{/if}
										var myChart = new JSChart('graph-{$deal.id}', 'pie');
										myChart.setDataArray(myData);
										myChart.colorizePie(colors);
										myChart.setTitleColor('#8E8E8E');
										myChart.setTitleFontSize(0);
										myChart.setTextPaddingTop(280);
										myChart.setPieValuesDecimals(1);
										myChart.setPieUnitsFontSize(0);
										if($.browser.msie)
											myChart.setPieValuesFontSize(0);
										else
											myChart.setPieValuesFontSize(100000000);
										myChart.setPieValuesColor('#fff');
										myChart.setPieUnitsColor('#969696');
										myChart.setSize(46, 46);
										myChart.setPiePosition(0, 0);
										myChart.setPieRadius(23);
										myChart.setFlagColor('#1BB8E3');
										myChart.setFlagRadius(4);
										myChart.setTooltipOpacity(1);
										myChart.setTooltipBackground('#ddf');
										myChart.setTooltipPosition('ne');
										myChart.setTooltipOffset(2);
										myChart.draw();
									</script>
								</td>
								<td>
									<span>{$deal.repay_time}</span>{if $deal.repay_time_type eq 0}天{else}个月{/if}
								</td>	
								<td>
									<a href="{$deal.url}">
										{if $deal.is_delete eq 2}
											<span class="f_white">待发布</span>
										{elseif $deal.is_wait eq 1}
											<span class="f_white">未开始</span>
										{elseif $deal.deal_status eq 5}
											<span class="f_white f_green">还款完毕</span>
										{elseif $deal.deal_status eq 4}
											<span class="f_white f_green">还款中</span>
										{elseif $deal.deal_status eq 0}
											<span class="f_white">等待材料</span>
										{elseif $deal.deal_status eq 1 && $deal.remain_time gt 0}
											<span class="f_white">筹款中</span>
										{elseif $deal.deal_status eq 2}
											<span class="f_white f_orange">满标</span>
										{elseif $deal.deal_status eq 3 || $deal.remain_time lte 0}
											<span class="f_white f_gray">流标</span>
										{/if}
									</a>
								</td>
							</tr>
							{/foreach}
							{else}
							<tr><td colspan="7">没有数据</td></tr>
							{/if}
						</tbody>
					</table>
				</div>
				<div class="pages">{$pages}</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	
	jQuery(function(){
		$("#case").find("li:odd").css("backgroundColor","#f9f9f9");

		var p_width=$(".i_deal_list p").width();
	   	var box_width=$(".i_deal_list .graph-box").width();
	   	var left_w=(box_width/2)-(p_width/2);
	   	$(".i_deal_list p").css("left",left_w+"px");

		$("#searchByKeyForm .searchinput").bind("focus",function(){
			if($.trim($(this).val())=="请输入您的搜索条件"){
				$(this).val("");
				$(this).removeClass("f_dgray");
			}
		});
		$("#searchByKeyForm .searchinput").bind("blur",function(){
			if($.trim($(this).val())=="请输入您的搜索条件" || $.trim($(this).val())==""){
				$(this).val("请输入您的搜索条件");
				$(this).addClass("f_dgray");
			}
		});
		
		$("#search_condition .j_more").click(function(){
			if(!$("#search_condition").hasClass("v")){
				$("#search_condition").css({"height":"270px"});
				$("#search_condition").addClass("v");
			}
			else{
				$("#search_condition").css({"height":"130px"});
				$("#search_condition").removeClass("v");
			}
		});
	});
	function searchByCondition(){
		$("#searchByConditionForm").submit();
	}
	function searchLoans(){
		if($.trim($("#searchByKeyForm .searchinput").val())=="请输入您的搜索条件" || $.trim($("#searchByKeyForm .searchinput").val())==""){
			$.showErr("请输入您的搜索条件");
			return false;
		}
		$("#searchByKeyForm").submit();
	};
	
	function calculate(){
		var amount=$("#calculateAmount").val();
        var interest=$("#calculateInterest").val();
        var month=$("#calculateMonth").val();
		var repayType = $("#repayType").val();

        if((amount.replace(/[ ]/g, "")) == "" || (amount.replace(/[ ]/g, "")) == null||amount==""||amount==null){
            $.showErr("请输入初始投资");
            return;
        }else{
            amount=$.trim(amount);
            if(/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/.test(amount)==false){
                $.showErr("初始投资只能为整数或者小数且最多只能有两位小数");
                return;
            }else{
                if(amount>1000000){
                    $.showErr("初始投资为100万以下");
                    return;
                }
            }
        }
        if((interest.replace(/[ ]/g, "")) == "" || (interest.replace(/[ ]/g, "")) == null||interest==""||interest==null){
            $.showErr("请输入年利率");
            return;
        }else{
            interest=$.trim(interest);
            if(/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/.test(interest)==false){
                $.showErr("年利率只能为整数或者小数且最多只能有两位小数");
                return;
            }else{
                if(interest>=100){
                    $.showErr("年利率必须在100%以下");
                    return false;
                }
            }
        }
        if((month.replace(/[ ]/g, "")) == "" || (month.replace(/[ ]/g, "")) == null||month==""||month==null){
            $.showErr("请输入投资期限");
            return;
        }else{
            month=$.trim(month);
            if(/^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/.test(month)==false){
                $.showErr("投资期限只能为整数或者小数且最多只能有两位小数");
                return;
            }else{
                if(month>100){
                    $.showErr("投资期限为100月以内");
                    return;
                }
            }
        }
        var value = 0;
	    var inters= interest /(100*12);
		if(repayType==0){
			value= month*amount*(inters*Math.pow((1+inters), month) / (Math.pow((1+inters),month)-1));
		}
		else if(repayType==1){
			value = parseFloat(amount) + parseFloat(inters*amount*month);
		}
		else if(repayType==2){
			value = parseFloat(amount) + parseFloat(inters*amount*month);
		}
		
        $("#lastValue").html(formatNum(value));
    }
</script>
{include file="inc/footer.html"}